﻿
@{
    ViewData["Title"] = "EditIndex";
    Layout = "~/Views/Share/_Layoutiframe.cshtml";
}

<script>
    var keyValue = $.request("ids");
    $(function () {
        $("#RID").bindSelect({
            url: "/User/GetRole",
            id: "id",
            text: "RoleName"
        });
        $("#OID").bindSelect({
            url: "/User/GetOffice",
            id: "id",
            text: "OfficeName"
        });
        if (!!keyValue) {
            $.ajax({
                url: "/User/GetFormList",
                data: { ids: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        }
        layui.use(['form', 'layedit', 'laydate'], function () {

            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            form.render();

        });
    });
    function submitForm() {
        $("#form1").validate({
            rules: {
                UserName: "required",
                LoginName: "required",
                LoginPWD: "required",
                LoginPWDTwo: {
                    equalTo: "#LoginPWD"
                }
            }
        });
        if ($('#form1').valid()) {
           $.loading(true, "正在提交数据");
            window.setTimeout(function () {
                $.ajax({
                    url: "/User/EditUser/",
                    data: $('#form1').serialize(),
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        if (data.errorMsg) {
                            top.layer.msg(data.errorMsg, { icon: 2 });
                        }
                        else {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            $.currentWindow().$("#list1").trigger("reloadGrid");
                            var msgs = (data.okMsg);
                            top.layer.msg(msgs, { icon: 1 });
                            parent.layer.close(index);
                        }

                    },
                    error: function () {
                        $.loading(false);

                    },
                    complete: function () {
                        $.loading(false);
                    }
                });

            }, 500);
        }
    }

</script>
<div style="margin-right:30px;padding-top:10px;">
    <form id="form1" class="layui-form">
        <div style="position:absolute;">
            <table class="form">
                <tr style="display:none;">
                    <th class="formTitle">用户编号</th>
                    <td class="formValue">
                        <input id="UserID" name="UserID" type="text" class="form-control input-sm" placeholder="请输入用户名" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">用户名</th>
                    <td class="formValue">
                        <input id="UserName" name="UserName" type="text" class="form-control input-sm" placeholder="请输入用户名"  />
                    </td>
                    <th class="formTitle">登录名</th>
                    <td class="formValue">
                        <input id="LoginName" name="LoginName" type="text" class="form-control input-sm" placeholder="请输入登录名"  />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">角色</th>
                    <td class="formValue">
                        <select id="RID" name="RID" lay-verify="required"  lay-search="">
                            <option value="">==请选择==</option>
                        </select>
                    </td>
                    <th class="formTitle">部门</th>
                    <td class="formValue">
                        <select id="OID" name="OID" lay-verify="required"  lay-search="">
                            <option value="">==请选择==</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">性别</th>
                    <td class="formValue">
                        <select id="Sex" name="Sex" lay-verify="required">
                            <option value="">==请选择==</option>
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </td>
                    <th class="formTitle">联系手机</th>
                    <td class="formValue">
                        <input id="Phone" name="Phone" type="text" class="form-control input-sm" placeholder="请输入联系方式" />
                    </td>
                </tr>

                <tr>
                    <th class="formTitle">备注</th>
                    <td class="formValue" colspan="3">
                        <textarea id="BZ" name="BZ" class="form-control input-sm" style="height: 120px;"></textarea>
                    </td>

                </tr>
               
            </table>
        </div>
    </form>
</div>
